//
//  DesCell.m
//  International_Hospital
//
//  Created by 李建强 on 16/7/6.
//  Copyright © 2016年 LiYiLin. All rights reserved.
//

#import "DesCell.h"
#import "DesModel.h"

@interface DesCell()


@end

@implementation DesCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.titleLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.titleLabel];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(20);
            make.centerY.equalTo(self.mas_centerY);
            
        }];
        
        self.tx_Label = [[UITextField alloc]init];
        
        self.tx_Label.font = [UIFont systemFontOfSize:16];
        [self.contentView addSubview:self.tx_Label];
        
        [self.tx_Label mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.left.equalTo(self.titleLabel.mas_right).offset(30);
            make.top.equalTo(self.titleLabel.mas_top);
            make.width.mas_equalTo(270);
//            make.right.equalTo(self.contentView).offset(-5);
            
        }];
        self.tx_Label.textAlignment = NSTextAlignmentLeft;
        
    }
    return self;
}



-(void)layoutSubviews{
    [super layoutSubviews];
    
    
    
}





-(void)setModel:(DesModel*)model{
    
   _model  = model;
    
    
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    self.titleLabel.text = model.title;

    self.titleLabel.font = [UIFont systemFontOfSize:17];
    if ([defaults objectForKey:self.titleLabel.text]) {

        self.tx_Label.text = [defaults objectForKey:self.titleLabel.text];
        
        
//        NSLog(@"%@",[defaults objectForKey:self.titleLabel.text]);
        return;
    }

    self.tx_Label.text = model.content;
    
}




@end
